package com.yanqu.road.server.cmd.marriage;

import com.yanqu.road.pb.worldmessage.WorldMessageProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.marriage.CrossMarriageGroupChatMgr;
import com.yanqu.road.server.manger.CrossMarriageGroupMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_MARRIAGE_CHAT_LIST, desc = "跨服联姻分组聊天列表")
public class CrossMarriageGroupChatListCmd extends CrossCommand {
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        int groupId = CrossMarriageGroupMgr.getGroupIdByServerId(serverId);
        userId = packet.getPlayerId();
        WorldMessageProto.WorldMessageListMsg.Builder msg = CrossMarriageGroupChatMgr.getChatListMsg(groupId);
        if(null == msg){
            msg = WorldMessageProto.WorldMessageListMsg.newBuilder();
        }
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_MARRIAGE_GROUP_CHAT_LIST_NOTIFY, msg);
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
